const express = require("express");

const app = express();
//导入mysql模块儿
const mysql = require("mysql");

let mysqlcon = mysql.createConnection({host:"127.0.0.1",port:"3306",user:"root",password:"root",database:"mydb"})
 
//设置查询语句 
let getdatasql = `select * from stuinfo`;

let info;
mysqlcon.query(getdatasql,(err,data)=>{  
    info = data;
})
app.listen(3000,()=>{
    console.log("3000端口打开");
})
app.get("/",(req,res)=>{
      res.send(info);
})